package com.mtsmda.bookjava7.chapter11.generics.myGeneric;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.mtsmda.bookjava7.chapter11.generics.GenericClassExtends;
import com.mtsmda.bookjava7.chapter11.generics.GenericConstructor;
import com.mtsmda.bookjava7.chapter11.generics.GenericDemo;
import com.mtsmda.bookjava7.chapter11.generics.GenericMethod;
import com.mtsmda.bookjava7.chapter11.generics.X;
import com.mtsmda.bookjava7.chapter11.generics.animals.AziyaDog;
import com.mtsmda.bookjava7.chapter11.generics.animals.Cat;
import com.mtsmda.bookjava7.chapter11.generics.animals.Dog;

public class RunGenerics {

	public static void main(String[] args) {
		List<Integer> integers = new ArrayList<Integer>();
		integers.add(new Integer(115));
		GenericClass<Integer> genericClass = new GenericClass<>(integers);
		Integer firstTElement = genericClass.getFirstTElement();
		System.out.println(firstTElement);

		System.out.println("\n - - - - - \n");

		TestGenericClass<Double, String, Boolean> testGenericClass = new TestGenericClass<>();
		Double[] doubles = { new Double(19.9), new Double(29.9) };
		Map<Integer, Boolean> map = new HashMap<Integer, Boolean>();
		map.put(19, true);
		map.put(25, false);

		testGenericClass.setkArray(doubles);
		testGenericClass.setvObject(new String("String"));
		testGenericClass.setMap(map);
		
		System.out.println(testGenericClass.getvObject());
		System.out.println(testGenericClass.getkArray());
		try {
			System.out.println(testGenericClass.getArrayValueByIndex(1));
			System.out.println(testGenericClass.getValueFromMap(25));
		} catch (Exception e) {
			System.out.println(e.getMessage());
		}
		
		
		System.out.println("\n - - - - - \n");
		
		
		new GenericClassExtends<Dog>();
//		new GenericClassExtends<Cat>();
		new GenericClassExtends<AziyaDog>();
		
		System.out.println("\n - - - - - \n");
		
		
		System.out.println(new GenericMethod().getT(integers).getClass().getSimpleName());
		
		
		System.out.println("\n - - - - - \n");
		
		System.out.println(new GenericConstructor(new GenericDemo()));
		
		new X(new String());
		
	}

}